package com.xuecheng.content.convert;

import com.xuecheng.api.content.model.dto.TeachplanDTO;
import com.xuecheng.api.content.model.vo.TeachplanVO;
import com.xuecheng.api.media.model.dto.TeachplanMediaDTO;
import com.xuecheng.content.entity.Teachplan;
import com.xuecheng.content.entity.TeachplanMedia;
import com.xuecheng.content.entity.ex.TeachplanNode;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;
import org.mapstruct.factory.Mappers;

import java.util.List;

@Mapper //标记为mapstruct转换器
public interface TeachplanConvert {

    TeachplanConvert INSTANCE = Mappers.getMapper(TeachplanConvert.class);

    @Mappings({
            @Mapping(source = "id",target = "teachPlanId"),
            @Mapping(source = "childrenNodes",target = "teachPlanTreeNodes")
    })
    TeachplanDTO teach2dto(TeachplanNode teachplanNode);

    //依赖于单个
    List<TeachplanDTO> teachs2dtos(List<TeachplanNode> nodes);

    @Mapping(source = "teachPlanId",target = "id")
    Teachplan dto2teachplan(TeachplanDTO teachplanDTO);

    //vo转dto
    TeachplanDTO vo2dto(TeachplanVO teachplanVO);

    //po转dto
    TeachplanDTO po2dto(Teachplan teachplan);


    TeachplanMedia dto2entity(TeachplanMediaDTO teachplanDTO);

    TeachplanMediaDTO entity2dto(TeachplanMedia teachplanMedia);

}
